Prevent infinite recursion and OOM in project_and_unify_term#156842
Prevent infinite recursion and OOM in project_and_unify_term#156842BloodStainedCrow wants to merge 1 commit into
project_and_unify_term#156842Conversation
|
rustbot has assigned @dingxiangfei2009. Use Why was this reviewer chosen?The reviewer was selected based on:
|
project_and_unify_term
|
I have added the recursion check to the "lowest" function which added the new obligation, So it might make sense to move this check further up to cover more of |
|
@rustbot reroll |
|
Sorry for the long wait. I'm not familiar with the code here enough to suggest anything here, but I might be able to find somebody more knowledgeable. r? project-trait-system-refactor BTW amazing work on your FactoryGame project ;) |
|
cjgillot you have 20 PRs assigned, so let me know if I should look for somebody else |
|
☔ The latest upstream changes (presumably #157894) made this pull request unmergeable. Please resolve the merge conflicts. |
|
I'm not confident to review this |
we should handle this limit in rust/compiler/rustc_trait_selection/src/traits/project.rs Lines 697 to 703 in 63f05e3 Where does the cycle occur to never trigger this? Does the overflow happen due to nested obligations from equating the output of |
| if !selcx.tcx().recursion_limit().value_within_limit(obligation.recursion_depth) { | ||
| selcx.infcx.err_ctxt().report_overflow_obligation(&obligation, false); | ||
| } | ||
| } |
There was a problem hiding this comment.
it seems like the overflow happens because inferred_obligations contains another Projection obligation which ends up causing the same thing yet again?
I would maybe just copy the overflow check of project to also happen at the start of this function?
Prevents an infinite recursion when using the old trait solver.
Fixes #156615.
Note that the example in #156615 encounters this infinite recursion in
report_ambiguity_errors.The overflow abort introduced here shadows the original error for which we are generating a report, which is unfortunate but preferable to hangs/OOMs:
Ideally, we could report the original error AND report the overflow while generating the report, something like this: